package com.akuhome.resource.controller;

import com.akuhome.resource.DO.check.use.ClassroomUse;
import com.akuhome.resource.DO.check.use.DormitoryUse;
import com.akuhome.resource.dto.check.FoodCheckInfo;
import com.akuhome.resource.service.check.AccCheckService;
import com.akuhome.resource.service.check.ClassroomCheckService;
import com.akuhome.resource.service.check.FoodCheckService;
import com.akuhome.resource.service.entity.ClassroomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/check")
public class CheckController {
    @Autowired
    AccCheckService accCheckService;
    @Autowired
    FoodCheckService foodCheckService;
    @Autowired
    ClassroomCheckService classroomCheckService;

    @GetMapping("/acc/{id}")
    public Object getDormitoryUseProject(@PathVariable  Integer id){
        return accCheckService.findDormitoryUseProject(id);
    }

    @PutMapping("/acc")
    public Object updateDormitoryUseList(@Validated @RequestBody List<DormitoryUse> dormitoryUseList,BindingResult bindingResult){
        accCheckService.updateDormitoryUsage(dormitoryUseList);
        return null;
    }

    @GetMapping("/food/{id}")
    public Object getFoodCheckInfoByProjectId(@PathVariable Integer id){
        return foodCheckService.findFoodCheckInfoByProjectId(id);
    }

    @PutMapping("/food")
    public Object updateFoodCheckInfo(@RequestBody @Validated FoodCheckInfo foodCheckInfo,BindingResult bindingResult){
        foodCheckService.updateFoodCheckInfo(foodCheckInfo);
        return null;
    }

    @GetMapping("/classroom/{id}")
    public Object getClassroomUseProject(@PathVariable Integer id){
        return classroomCheckService.findClassroomUseProject(id);
    }
    @PutMapping("/classroom")
    public Object updateClassroomUseList(@Validated @RequestBody List<ClassroomUse> classroomUseList, BindingResult bindingResult){
        classroomCheckService.updateClassroomUsage(classroomUseList);
        return null;
    }
}
